package com.leo.foodmaster.commons.config.security;

import com.leo.foodmaster.admin.system.service.IPermissionService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

/**
 * <p>
 * 容器启动完成时加载角色权限规则至Redis缓存
 * </p>
 *
 * @author ：Leo
 * @since ：2021-05-13 15:09
 */
@Component
@AllArgsConstructor
@Slf4j
public class InitPermissionRoles implements CommandLineRunner {

    private final IPermissionService permissionService;

    @Override
    public void run(String... args) {
        log.info("加载角色权限规则至Redis缓存...");
        permissionService.refreshPermissionRolesToCache();
    }

}
